<?php namespace Admin\Controller;
use Common\Model\Tatt;

class AttlistController extends CommonController
{
    private $model;

    public function __auto()
    {
        $this->model = new Tatt();
    }

//    显示属性类型
    public function index(){
        $tid=$_SESSION['info']['tid'];
        $data=$this->model->where("shop_type_tid={$tid}")->get();
//        p($data);
        View::with('data',$data);
//        p($_SESSION);die;
        View::make();
    }

//    添加属性
    public function addattlist()
    {
        if (IS_POST) {
            if ($this->model->store()) {
//                die;
                View::success('添加成功', U('index'));
            } else {
                View::error($this->model->getError());
            }
        }
        View::make();
    }

//    删除属性
    public function delattlist(){
        $taid=Q('get.taid',0,'intval');
        $this->model->where("taid={$taid}")->delete();
        View::success('删除属性成功');
    }

//    编辑属性
    public function editattlist(){
        if(IS_POST){
            if($this->model->edit()){
                View::success('编辑成功',U('index'));
            }else{
                View::error($this->model->getError());
            }
        }

        $taid=Q('get.taid',0,'intval');
        $data=$this->model->where("taid={$taid}")->first();
        View::with('data',$data);
        View::make();
    }
}